//
//  HJChatMessageFileCell.m
//  XWC
//
//  Created by Hello on 2022/10/25.
//

#import "HJChatMessageFileCell.h"
#import "HJChatMessageFileLayout.h"
#import "HJChatMessageLayout.h"
#import "HJChatMessageModel.h"

@interface HJChatMessageFileCell()

@property (nonatomic, weak) UIImageView *fileIcon;
@property (nonatomic, weak) UILabel *fileNameLabel;
@property (nonatomic, weak) UILabel *fileSizeLabel;

@end


@implementation HJChatMessageFileCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
      
        UIImageView *fileIcon = [UIImageView addToView:self.bubbleView];
        fileIcon.contentMode = UIViewContentModeScaleAspectFit;
        
        UILabel *fileNameLabel = [UILabel lableWithSuperView:self.bubbleView font:UIFontMake(16) color:UIColor.tj_333333Color title:nil textAlignment:NSTextAlignmentLeft];
        fileNameLabel.numberOfLines = 0;
        
        UILabel *fileSizeLabel = [UILabel lableWithSuperView:self.bubbleView font:UIFontMake(11) color:UIColor.tj_999999Color title:nil textAlignment:NSTextAlignmentLeft];
        fileNameLabel.numberOfLines = 0;
        
        _fileIcon = fileIcon;
        _fileNameLabel = fileNameLabel;
        _fileSizeLabel = fileSizeLabel;
        
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    HJChatMessageFileLayout *fileFactory = (HJChatMessageFileLayout *)self.messageLayout;
    _fileIcon.frame = fileFactory.fileIconRect;
    _fileNameLabel.frame = fileFactory.fileNameRect;
    _fileSizeLabel.frame = fileFactory.fileSizeRect;
 }

- (void)setMessageLayout:(HJChatMessageLayout *)messageLayout {
    [super setMessageLayout:messageLayout];
    
    HJChatMessageFileLayout *fileFactory = (HJChatMessageFileLayout *)self.messageLayout;
//    _fileIcon.image = [UIImage imageNamed:[HJTools fileIconWithFileName:fileFactory.fileName]];
    _fileNameLabel.text = fileFactory.fileName;
    _fileSizeLabel.text = fileFactory.fileSizeString;

}


@end
